<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>{$Think.config.site.title} - 个人资料</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">

    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
      <div class="row">
          <div class="col-sm-12">
              <div class="ibox float-e-margins">
                  <div class="ibox-title">
                      <h5>帐号信息</h5> 
                      <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                      </div>
                  </div>
                  <div class="ibox-content">
                  	<p><img width=200 height=200 alt="image"  src="{$Think.cookie.avatar}" /></p>
                    <p>用户名：{$user['username']}</p>
                    <p>权限组：{$groupname}</p>
                    <p>上次登录时间：{$user['last_login_time']}</p>
                    <p>上次登录IP：{$user['last_login_ip']}</p>
                  </div>
              </div>
          </div>
      </div>
      <div class="row">
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>个人资料 </h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                      	</div>
         
                    </div>
                    <div class="ibox-content">
                        <form method="get" class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">姓名：</label>
                                <div class="col-sm-10">
                                    <input id="name" name="name" class="form-control" type="text" value="{$user['name']}">

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">昵称：</label>
                                <div class="col-sm-10">
                                    <input id="nickname" name="nickname" class="form-control" type="text" value="{$user['nickname']}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">手机号码：</label>
                                <div class="col-sm-10">
                                    <input id="phone" name="phone" class="form-control" type="text" value="{$user['phone']}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">邮箱：</label>
                                <div class="col-sm-10">
                                    <input id="email" name="email" class="form-control" type="email" value="{$user['email']}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">修改</button>
                           
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/content.min.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
  <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
</body>

</html>
<script>
$(document).ready(function(){
	$("form").validate({
	  debug:true,
	  submitHandler:function(form){
            post();   
      },
	  rules: {
		phone: {
		  number: true,
		  minlength: 6,
		}
	  },
	  messages: {
		phone: {
		  number: '手机号码只能包含数字',
		  minlength: '手机号码不能少于6位',
		}
	  }
	});
	function post(){
		var fomrData = $("form").serialize();
		$.ajax({
			type : 'POST',
			url : '<?php echo \think\Request::instance()->root(); ?>/admin/Profile',
			dataType : 'json',
			data : fomrData,
			success : function(result) {
				//layer.close(layer1);
				if(0 === result.code) {
					layer.msg('修改成功！', {icon: 1});
				}  else  {
					//修改失败
					layer.msg(result.msg, {icon: 5});
				}
			},
			error : function(){
				layer.msg('服务器错误！请稍后重试', {icon: 2});
			}
		})
	};
})
</script>